import pandas as pd
pd.set_option('display.unicode.east_asian_width',True)
df = pd.read_excel('D:/ITaudit/pandas_excel/Orders1.xlsx')
# df1 = df[['Category','Total','numbers']]
# # print(df1.groupby('Category').sum())#分组统计求和数据，都对total和numbers求和
# print(df1.groupby('Category')['numbers'].sum())#指定条件仅对数量分组统计求和
# for name,group in df1.groupby('Category'):
#     print(name,group)
# df2 = df[['Category','Subcategor','numbers']]#多列分组迭代
# for (k1,k2),group in df2.groupby(['Category','Subcategor']):
#     print(k1,k2)
#     print(group)
# df3 = df[['Category','numbers']]
# print(df3.groupby('Category').agg(['sum']))
# 对不同的列进行不同的聚合函数
# df4 = df[['Category','numbers','Total']]
# print(df4.groupby('Category').agg({'numbers':['sum','mean'],'Total':['max']}))
print(df['Category'].value_counts())#分组统计一列降序计数
#通过字典或series对象分组统计
